package com.hos.punchtheclocksystem.controller;


import com.hos.punchtheclocksystem.pojo.IndexCard;
import com.hos.punchtheclocksystem.service.Card001Service;
import com.hos.punchtheclocksystem.service.CardService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RequestMapping("/api/indexcard")
@RestController
public class CardController {
    @Autowired
    CardService cardService;
    @Autowired
    Card001Service card001Service;

    @GetMapping("/day")
    public List<IndexCard> getDay(){
        List<IndexCard> cardlist= cardService.getDay();
        for (IndexCard indexCard : cardlist) {
            if (card001Service.selectCardToday(indexCard.getDocid())==null){
                indexCard.setIspost(2);
            }else {
                indexCard.setIspost(1);
            }
        }
        return cardlist;
    }
}
